//
// Created by Wirano on 2020/11/13.
//

#ifndef DRV_OPENMV_H
#define DRV_OPENMV_H

#include "Ano_FcData.h"

//==定义
typedef struct
{
    //
    uint8_t color_flag;
    uint8_t sta;
    int16_t pos_x;
    int16_t pos_y;
    uint8_t dT_ms;

} _openmv_color_block_st;

typedef struct
{
    //
    uint8_t sta;
    int16_t angle;
    int16_t deviation;
    uint8_t p_flag;
    int16_t pos_x;
    int16_t pos_y;
    uint8_t dT_ms;

} _openmv_line_tracking_st;

typedef struct
{
    uint8_t offline;//模块是否掉线
    uint8_t mode_cmd;
    uint8_t mode_sta;
    //
    _openmv_color_block_st cb;//色块识别状态
    _openmv_line_tracking_st lt; //巡线相关
} _openmv_data_st;
extern _openmv_data_st opmv;

typedef struct
{
    uint8_t angle;
    uint8_t len;
    int16_t start_x;
    int16_t start_y;
} _openmv_object_line;

typedef enum
{
    OMV_COLOR_WHITE,
    OMV_COLOR_BLACK,
    OMV_COLOR_RED,
    OMV_COLOR_GREEN,
    OMV_COLOR_BLUE,
    OMV_COLOR_NUM
} _openmv_object_color_type;

typedef enum
{
    OMV_SHAPE_CIRCLE,
    OMV_SHAPE_RECTANGLE,
    OMV_SHAPE_TRIANGLE,
    OMV_SHAPE_NUM
} _openmv_object_shape_type;

typedef struct
{
    _openmv_object_shape_type shape;
    _openmv_object_color_type color;
    int16_t center_x;
    int16_t center_y;
} _openmv_object_shape;


//static
static void OpenMV_Data_Analysis(uint8_t *buf_data, uint8_t len);

static void OpenMV_Check_Reset(void);

//public
void OpenMV_Offline_Check(uint8_t dT_ms);

void OpenMV_Byte_Get(uint8_t bytedata);

#endif //ADRV_OPENMV_H
